package com.ruoyi.web.controller.insect.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.insect.domain.DiseaseLabel;
import com.ruoyi.insect.service.IDiseaseLabelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 数据标注Controller
 * 
 * @author ruoyi
 * @date 2025-08-26
 */
@RestController
@RequestMapping("/insect/label")
public class DiseaseLabelController extends BaseController
{
    @Autowired
    private IDiseaseLabelService diseaseLabelService;

    /**
     * 查询数据标注列表
     */
    @PreAuthorize("@ss.hasPermi('insect:label:list')")
    @GetMapping("/list")
    public TableDataInfo list(DiseaseLabel diseaseLabel)
    {
        startPage();
        List<DiseaseLabel> list = diseaseLabelService.selectDiseaseLabelList(diseaseLabel);
        return getDataTable(list);
    }

    /**
     * 导出数据标注列表
     */
    @PreAuthorize("@ss.hasPermi('insect:label:export')")
    @Log(title = "数据标注", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DiseaseLabel diseaseLabel)
    {
        List<DiseaseLabel> list = diseaseLabelService.selectDiseaseLabelList(diseaseLabel);
        ExcelUtil<DiseaseLabel> util = new ExcelUtil<DiseaseLabel>(DiseaseLabel.class);
        util.exportExcel(response, list, "数据标注数据");
    }

    /**
     * 获取数据标注详细信息
     */
    @PreAuthorize("@ss.hasPermi('insect:label:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(diseaseLabelService.selectDiseaseLabelById(id));
    }

    /**
     * 新增数据标注
     */
    @PreAuthorize("@ss.hasPermi('insect:label:add')")
    @Log(title = "数据标注", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DiseaseLabel diseaseLabel)
    {
        return toAjax(diseaseLabelService.insertDiseaseLabel(diseaseLabel));
    }

    /**
     * 修改数据标注
     */
    @PreAuthorize("@ss.hasPermi('insect:label:edit')")
    @Log(title = "数据标注", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DiseaseLabel diseaseLabel)
    {
        return toAjax(diseaseLabelService.updateDiseaseLabel(diseaseLabel));
    }

    /**
     * 删除数据标注
     */
    @PreAuthorize("@ss.hasPermi('insect:label:remove')")
    @Log(title = "数据标注", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(diseaseLabelService.deleteDiseaseLabelByIds(ids));
    }
}
